<?
require_once("../config/dbconn.php");require_once("../config/usercls.php");require_once("../config/pagecls.php");

$sqlhy="select * from {$db_prefix}users where id='".$_SESSION['sys_userid']."'";
$rshy=$db->get_one($sqlhy);

if($act=='hyzmd'){
	$msg='';
	if(trim($zmdname)=='') $msg.="请输入服务中心名称\\n";
	if(trim($province)=='') $msg.="请选择省份\\n";
	if(trim($city)=='') $msg.="请选择城市\\n";
	if(trim($area)=='') $msg.="请选择县区\\n";
	if(trim($address)=='') $msg.="请输入服务中心详细地址\\n";
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	
	$sqlchk="select * from {$db_prefix}applyzmd where username='".$_SESSION['sys_username']."' and state=0";
	$rschk=$db->get_one($sqlchk);
	if ($rschk){
		$msg.="您已经申请过了\\n\\n请耐心等待管理员申请";
	}
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	
	//判断是否有足够的报单币
	/*
	if($glo_zmdsqkbdprice==1){
		$glornamebd="glo_zmdregprice_".$zmdrank;
		if($rshy['price']<$$glornamebd){
			$msg.="您没有足够的报单币\\n";
			echo "<script>alert('$msg');history.back();</script>";exit();
		}
	}*/
	//看是否推荐了｛$glo_fwzxnum｝个人了
	/*$sqltj="select count(id) as c from {$db_prefix}users where tjuser='".$_SESSION["sys_username"]."' and state=1";
	$rstj=$db->get_one($sqltj);
	$tjnum=intval($rstj['c']);
	if ($tjnum<$glo_fwzxnum){
		$msg.="必须推荐{$glo_fwzxnum}个人才能申请报单中心\\n\\n";
	}
	*/
	
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	
	//插入申请记录中
	unset($dataArray);
	$dataArray['username']=$_SESSION['sys_username'];
	$dataArray['zmdname']=trim($zmdname);
	$dataArray['zmdrank']=$zmdrank;
	$dataArray['zmdprovince']=$province;
	$dataArray['zmdcity']=$city;
	$dataArray['zmdarea']=$area;
	$dataArray['zmdaddress']=trim($address);
	$dataArray['addtime']=$curtime;
	$dataArray['state']=0;
	$dataArray['edittime']=0;
	$db->insert("{$db_prefix}applyzmd",$dataArray);
	
	echo "<script>alert('申请已经提交\\n\\n请等待管理员审核');location.href='user_zmdlst.php';</script>";exit();
}

if($action=='del'){
	$db->delete("{$db_prefix}applyzmd","id='$id'");
	echo "<script>location.href='user_zmdlst.php?pageno={$pageno}';</script>";exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/user_zmd.js"></script>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	
}
td{
font-size:12px;
}
.red{
	color:#FF0000
}
.hmgc001 {
	font-size: 14px;
	font-weight: bold;
	color: #ffffff;
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" ></td>
    <td width="100%" height="29" valign="top" ><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">申请服务中心/Apply to the Fund Center</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" ></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg1.png">&nbsp;</td>
    <td valign="top"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top">
		  <table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td height="13" valign="top">&nbsp;</td>
            </tr>
            <tr>
              <td align="center" valign="top"><?
		if ($rshy['isdp']==1){
		?>
                您已经是服务中心了！
                <?
		}else{
		?>
        <form id="form1" name="form1" method="post" action="?act=hyzmd">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="3"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                  <tr>
                    <td class="left_bt2"></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30" colspan="3"><table width="100%" height="180" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="30" align="center" class="left_txt">会员/Member</td>
                    <td height="30" class="left_txt"><?=$rshy['username']?></td>
                  </tr>
                  <tr>
                    <td height="30" align="center" class="left_txt">现在级别/Now level</td>
                    <td height="30" class="left_txt"><?=$hyrankary[$rshy['rank']]?></td>
                  </tr>
                  <tr>
                    <td height="30" align="center" class="left_txt">申请服务中心/Fund Center Name</td>
                    <td height="30" class="left_txt"><input name="zmdname" type="text" id="zmdname" size="40">
                        <span class="red">*</span></td>
                  </tr>
                  <tr>
                    <td height="30" align="center" class="left_txt">申请级别/Application level</td>
                    <td height="30" class="left_txt"><label>
                      <select name="zmdrank" id="zmdrank">
                        <?
					foreach($zmdrankary as $k1=>$v1){
						echo "<option value='{$k1}'>{$v1}</option>";
					}
					?>
                      </select>
                      <span class="red">*</span></label></td>
                  </tr>
                  <tr>
                    <td height="30" align="center" class="left_txt">服务中心所在区域/Fund Center area</td>
                    <td height="30" class="left_txt"><p> 省份/Province：
                      <select name="province" id="province" onChange="provincechange(this.value)" style="width:140px;">
                              <option value="">请选择/Please select</option>
                              <?
					   $sqlsf="select * from {$db_prefix}province where 1";
					   $resultsf=$db->query($sqlsf);
					   while($rssf=$db->fetch_array($resultsf)){
					   	echo "<option value='{$rssf['provinceID']}'>{$rssf['province']}</option>";
					   }
					   $db->free_result($resultsf);
					   ?>
                            </select>
                      </p>
                        <p>城市/City：
                          <select name="city" id="city" onChange="citychange(this.value)" style="width:160px;">
                            </select>
                        </p>
                      <p>区县/Counties：
                        <select name="area" id="area" style="width:160px;">
                            </select>
                            <span class="red">* </span> </p>
                      <label id="province_notice" class="red"></label></td>
                  </tr>
                  <tr>
                    <td height="30" align="center" class="left_txt">服务中心详细地址/Fund Center Address</td>
                    <td height="30" class="left_txt"><input name="address" type="text" size="60">
                        <label><span class="red"> * </span></label></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30" colspan="3" align="center" class="red"><label id="reg_notice" class="red"></label>
                  <br>
                  <?
			  if ($glo_zmdsqkbdprice==1) echo "您的账户报单余额:".$rshy['price']."人民币";
			  ?>
              </td>
            </tr>
            <tr>
              <td width="50%" height="30" align="right"><input type="submit" value="申请/Application" name="B1" /></td>
              <td width="6%" height="30" align="right">&nbsp;</td>
              <td width="44%" height="30">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
          </table>
        </form>
                <?
		  }
		  ?>
              </td>
            </tr>
          </table>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                <tr>
                  <td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;</td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30"><table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="30" align="center" bgcolor="#f2f2f2" >编号/Number</td>
                  <td align="center" bgcolor="#f2f2f2" >会员/Member</td>
                  <td align="center" bgcolor="#f2f2f2" >服务中心名称/Fund Center Name</td>
                  <td align="center" bgcolor="#f2f2f2" >服务中心级别/Fund center level</td>
                  <td align="center" bgcolor="#f2f2f2" >服务中心地区/Fund central</td>
                  <td align="center" bgcolor="#f2f2f2" >服务中心详细地址/Fund Center Address</td>
                  <td align="center" bgcolor="#f2f2f2" >状态/Status</td>
                  <td align="center" bgcolor="#f2f2f2" >申请时间/Application Period</td>
                  <td align="center" bgcolor="#f2f2f2" >审核时间/Audit time</td>
                  <td height="30" align="center" bgcolor="#f2f2f2" >操作/Operating</td>
                  </tr>
  <?
  $query='';
  if ($action=='query'){
  	
  }
  $sql="select count(id) as c  from {$db_prefix}applyzmd where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $rs=$db->get_one($sql);
  $page=new pagecls(20,intval($rs['c']));
  $sql="select * from {$db_prefix}applyzmd where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $sql.=" order by id desc limit {$page->pastnum},{$page->pagesize}";
  $result=$db->query($sql);
  while($rs=$db->fetch_array($result)){
  ?>
                <tr>
                  <td align="center"><?=$rs['id']?></td>
                  <td align="center"><?=$rs['username']?></td>
                  <td align="center"><?=$rs['zmdname']?></td>
                  <td align="center"><?=$zmdrankary[$rs['zmdrank']]?></td>
                  <td align="center"><?=getprovince($rs['zmdprovince']).'-'.getcity($rs['zmdcity']).'-'.getarea($rs['zmdarea'])?></td>
                  <td align="center"><?=$rs['zmdaddress']?></td>
                  <td align="center" ><? if($rs['state']==0) echo "未处理";elseif($rs['state']==1) echo "已升级";else echo "已拒绝";?></td>
                  <td align="center" ><?=date("Y-m-d H:i:s",$rs['addtime'])?></td>
                  <td align="center" ><? if ($rs['edittime']>0) echo date("Y-m-d H:i:s",$rs['edittime'])?></td>
                  <td height="30" align="center" ><a href="?action=del&id=<?=$rs['id']?>&pageno=<?=$page->pageno?>">删除</a></td>
                  </tr>
	<?
  }
  $db->free_result($result);
  ?>
              </table></td>
            </tr>
            
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" align="right">每页/Per<?=$page->pagesize?>条/Article 第/First<?=$page->pageno?>/<?=$page->pagenum?>页/Page 共/Common<?=$page->recnum?>条/Article <a href='?<?=$page->url?>1'><img src="image1/first.gif" border="0"></a>   <a href='?<?=$page->url.($page->pageno-1)?>'><img src="image1/back.gif" border="0"></a>  <a href='?<?=$page->url.($page->pageno+1)?>'><img src="image1/next.gif" border="0"></a>   <a href='?<?=$page->url.$page->pagenum?>'><img src="image1/last.gif" border="0"></a></td>
              </tr>
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.png">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" ></td>
      <td height="17" valign="top" ></td>
    <td></td>
  </tr>
</table>

</body>
</html>
